package pe.gob.mtpe.renoccsys.mybatis.implementacion;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import pe.gob.mtpe.renoccsys.bean.TipempresaD;
import pe.gob.mtpe.renoccsys.mybatis.comun.MyBatisConnectionFactory;
import pe.gob.mtpe.renoccsys.mybatis.interfase.INTTipempresa;

public class IMPTipempresa implements INTTipempresa {
	
private SqlSessionFactory sqlSessionFactory;
	
	public IMPTipempresa(){
		sqlSessionFactory=MyBatisConnectionFactory.getSqlSessionFactory();
	}


	@Override
	public void insertar(TipempresaD objTipoEmpresa) throws Exception {
		
		SqlSession session = sqlSessionFactory.openSession();

		try {
			
		    session.delete("TipempresaD.deleteTipempresaD",objTipoEmpresa);
		    session.insert("TipempresaD.insertar",objTipoEmpresa);
						
			session.commit();
			
		} 
		catch(Exception ex){
			session.rollback();
			
		}
		finally {
			session.close();
		}

	}

}
